/**
 *
 */
import Util;
import OSS;
import RPC;
import OpenPlatform;
import OSSUtil;
import FileForm;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  
  checkConfig(config);
  @endpoint = getEndpoint('ivpd', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model ChangeImageSizeRequest {
  height?: int32(name='Height'),
  url?: string(name='Url'),
  width?: int32(name='Width'),
}

model ChangeImageSizeResponseBody = {
  code?: string(name='Code'),
  data?: {
    url?: string(name='Url'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model ChangeImageSizeResponse = {
  headers: map[string]string(name='headers'),
  body: ChangeImageSizeResponseBody(name='body'),
}

async function changeImageSizeWithOptions(request: ChangeImageSizeRequest, runtime: Util.RuntimeOptions): ChangeImageSizeResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.height)) {
    body['Height'] = request.height;
  }
  if (!Util.isUnset(request.url)) {
    body['Url'] = request.url;
  }
  if (!Util.isUnset(request.width)) {
    body['Width'] = request.width;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ChangeImageSize',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function changeImageSize(request: ChangeImageSizeRequest): ChangeImageSizeResponse {
  var runtime = new Util.RuntimeOptions{};
  return changeImageSizeWithOptions(request, runtime);
}

model CreateSegmentBodyJobRequest {
  dataList?: [ 
    {
      dataId?: string(name='DataId'),
      imageUrl?: string(name='ImageUrl'),
    }
  ](name='DataList'),
  jobId?: string(name='JobId'),
  timeToLive?: int32(name='TimeToLive'),
}

model CreateSegmentBodyJobResponseBody = {
  code?: string(name='Code'),
  data?: {
    batchSize?: int32(name='BatchSize'),
    completed?: boolean(name='Completed'),
    jobId?: string(name='JobId'),
    progress?: int32(name='Progress'),
    resultList?: [ 
      {
        code?: string(name='Code'),
        dataId?: string(name='DataId'),
        message?: string(name='Message'),
        resultData?: {
          imageUrl?: string(name='ImageUrl'),
        }(name='ResultData'),
        success?: boolean(name='Success'),
      }
    ](name='ResultList'),
    status?: string(name='Status'),
    totalUsedTime?: long(name='TotalUsedTime'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model CreateSegmentBodyJobResponse = {
  headers: map[string]string(name='headers'),
  body: CreateSegmentBodyJobResponseBody(name='body'),
}

async function createSegmentBodyJobWithOptions(request: CreateSegmentBodyJobRequest, runtime: Util.RuntimeOptions): CreateSegmentBodyJobResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.dataList)) {
    body['DataList'] = request.dataList;
  }
  if (!Util.isUnset(request.jobId)) {
    body['JobId'] = request.jobId;
  }
  if (!Util.isUnset(request.timeToLive)) {
    body['TimeToLive'] = request.timeToLive;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateSegmentBodyJob',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createSegmentBodyJob(request: CreateSegmentBodyJobRequest): CreateSegmentBodyJobResponse {
  var runtime = new Util.RuntimeOptions{};
  return createSegmentBodyJobWithOptions(request, runtime);
}

model DetectImageElementsRequest {
  url?: string(name='Url'),
}

model DetectImageElementsResponseBody = {
  code?: string(name='Code'),
  data?: {
    elements?: [ 
      {
        height?: int32(name='Height'),
        score?: float(name='Score'),
        type?: string(name='Type'),
        width?: int32(name='Width'),
        x?: int32(name='X'),
        y?: int32(name='Y'),
      }
    ](name='Elements'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model DetectImageElementsResponse = {
  headers: map[string]string(name='headers'),
  body: DetectImageElementsResponseBody(name='body'),
}

async function detectImageElementsWithOptions(request: DetectImageElementsRequest, runtime: Util.RuntimeOptions): DetectImageElementsResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.url)) {
    body['Url'] = request.url;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DetectImageElements',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function detectImageElements(request: DetectImageElementsRequest): DetectImageElementsResponse {
  var runtime = new Util.RuntimeOptions{};
  return detectImageElementsWithOptions(request, runtime);
}

model EraseLogoInVideoRequest {
  boxes?: [ 
    {
      h?: float(name='H'),
      w?: float(name='W'),
      x?: float(name='X'),
      y?: float(name='Y'),
    }
  ](name='Boxes'),
  jobId?: string(name='JobId'),
  videoUrl?: string(name='VideoUrl'),
}

model EraseLogoInVideoResponseBody = {
  code?: string(name='Code'),
  data?: {
    jobId?: string(name='JobId'),
    videoUrl?: string(name='VideoUrl'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model EraseLogoInVideoResponse = {
  headers: map[string]string(name='headers'),
  body: EraseLogoInVideoResponseBody(name='body'),
}

async function eraseLogoInVideoWithOptions(request: EraseLogoInVideoRequest, runtime: Util.RuntimeOptions): EraseLogoInVideoResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.boxes)) {
    body['Boxes'] = request.boxes;
  }
  if (!Util.isUnset(request.jobId)) {
    body['JobId'] = request.jobId;
  }
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'EraseLogoInVideo',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function eraseLogoInVideo(request: EraseLogoInVideoRequest): EraseLogoInVideoResponse {
  var runtime = new Util.RuntimeOptions{};
  return eraseLogoInVideoWithOptions(request, runtime);
}

model ExtendImageStyleRequest {
  majorUrl?: string(name='MajorUrl'),
  styleUrl?: string(name='StyleUrl'),
}

model ExtendImageStyleResponseBody = {
  code?: string(name='Code'),
  data?: {
    majorUrl?: string(name='MajorUrl'),
    url?: string(name='Url'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model ExtendImageStyleResponse = {
  headers: map[string]string(name='headers'),
  body: ExtendImageStyleResponseBody(name='body'),
}

async function extendImageStyleWithOptions(request: ExtendImageStyleRequest, runtime: Util.RuntimeOptions): ExtendImageStyleResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.majorUrl)) {
    body['MajorUrl'] = request.majorUrl;
  }
  if (!Util.isUnset(request.styleUrl)) {
    body['StyleUrl'] = request.styleUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ExtendImageStyle',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function extendImageStyle(request: ExtendImageStyleRequest): ExtendImageStyleResponse {
  var runtime = new Util.RuntimeOptions{};
  return extendImageStyleWithOptions(request, runtime);
}

model GetAsyncJobResultRequest {
  jobId?: string(name='JobId'),
}

model GetAsyncJobResultResponseBody = {
  data?: {
    errorCode?: string(name='ErrorCode'),
    errorMessage?: string(name='ErrorMessage'),
    jobId?: string(name='JobId'),
    result?: string(name='Result'),
    status?: string(name='Status'),
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model GetAsyncJobResultResponse = {
  headers: map[string]string(name='headers'),
  body: GetAsyncJobResultResponseBody(name='body'),
}

async function getAsyncJobResultWithOptions(request: GetAsyncJobResultRequest, runtime: Util.RuntimeOptions): GetAsyncJobResultResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.jobId)) {
    body['JobId'] = request.jobId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetAsyncJobResult',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getAsyncJobResult(request: GetAsyncJobResultRequest): GetAsyncJobResultResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAsyncJobResultWithOptions(request, runtime);
}

model GetAsyncResultRequest {
  jobId?: string(name='JobId'),
}

model GetAsyncResultResponseBody = {
  code?: string(name='Code'),
  data?: {
    batchSize?: string(name='BatchSize'),
    code?: string(name='Code'),
    completed?: boolean(name='Completed'),
    finish?: boolean(name='Finish'),
    message?: string(name='Message'),
    progress?: float(name='Progress'),
    result?: map[string]any(name='Result'),
    status?: string(name='Status'),
    totalUsedTime?: long(name='TotalUsedTime'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model GetAsyncResultResponse = {
  headers: map[string]string(name='headers'),
  body: GetAsyncResultResponseBody(name='body'),
}

async function getAsyncResultWithOptions(request: GetAsyncResultRequest, runtime: Util.RuntimeOptions): GetAsyncResultResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.jobId)) {
    body['JobId'] = request.jobId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetAsyncResult',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getAsyncResult(request: GetAsyncResultRequest): GetAsyncResultResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAsyncResultWithOptions(request, runtime);
}

model GetJobResultRequest {
  jobId?: string(name='JobId'),
}

model GetJobResultResponseBody = {
  code?: string(name='Code'),
  data?: {
    batchSize?: string(name='BatchSize'),
    completed?: boolean(name='Completed'),
    finish?: boolean(name='Finish'),
    message?: string(name='Message'),
    progress?: float(name='Progress'),
    resultList?: [  map[string]any ](name='ResultList'),
    status?: string(name='Status'),
    totalUsedTime?: long(name='TotalUsedTime'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model GetJobResultResponse = {
  headers: map[string]string(name='headers'),
  body: GetJobResultResponseBody(name='body'),
}

async function getJobResultWithOptions(request: GetJobResultRequest, runtime: Util.RuntimeOptions): GetJobResultResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.jobId)) {
    body['JobId'] = request.jobId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetJobResult',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getJobResult(request: GetJobResultRequest): GetJobResultResponse {
  var runtime = new Util.RuntimeOptions{};
  return getJobResultWithOptions(request, runtime);
}

model GetJobStatusRequest {
  jobId?: string(name='JobId'),
}

model GetJobStatusResponseBody = {
  code?: string(name='Code'),
  data?: {
    batchSize?: string(name='BatchSize'),
    completed?: boolean(name='Completed'),
    finish?: boolean(name='Finish'),
    message?: string(name='Message'),
    progress?: float(name='Progress'),
    status?: string(name='Status'),
    timeToLive?: int32(name='TimeToLive'),
    totalUsedTime?: long(name='TotalUsedTime'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model GetJobStatusResponse = {
  headers: map[string]string(name='headers'),
  body: GetJobStatusResponseBody(name='body'),
}

async function getJobStatusWithOptions(request: GetJobStatusRequest, runtime: Util.RuntimeOptions): GetJobStatusResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.jobId)) {
    body['JobId'] = request.jobId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetJobStatus',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getJobStatus(request: GetJobStatusRequest): GetJobStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return getJobStatusWithOptions(request, runtime);
}

model GetUserBucketConfigResponseBody = {
  code?: string(name='Code'),
  data?: [ 
    {
      bucket?: string(name='Bucket'),
      region?: string(name='Region'),
      regionName?: string(name='RegionName'),
    }
  ](name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model GetUserBucketConfigResponse = {
  headers: map[string]string(name='headers'),
  body: GetUserBucketConfigResponseBody(name='body'),
}

async function getUserBucketConfigWithOptions(runtime: Util.RuntimeOptions): GetUserBucketConfigResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'GetUserBucketConfig',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getUserBucketConfig(): GetUserBucketConfigResponse {
  var runtime = new Util.RuntimeOptions{};
  return getUserBucketConfigWithOptions(runtime);
}

model HighlightGameVideoRequest {
  async?: boolean(name='Async'),
  videoUrl?: string(name='VideoUrl'),
}

model HighlightGameVideoAdvanceRequest {
  videoUrlObject: readable(name='VideoUrlObject'),
  async?: boolean(name='Async'),
}

model HighlightGameVideoResponseBody = {
  data?: {
    gameList?: [ 
      {
        end?: float(name='End'),
        gameInfo?: map[string]any(name='GameInfo'),
        id?: string(name='Id'),
        start?: float(name='Start'),
      }
    ](name='GameList'),
    highlightList?: [ 
      {
        end?: float(name='End'),
        start?: float(name='Start'),
      }
    ](name='HighlightList'),
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model HighlightGameVideoResponse = {
  headers: map[string]string(name='headers'),
  body: HighlightGameVideoResponseBody(name='body'),
}

async function highlightGameVideoWithOptions(request: HighlightGameVideoRequest, runtime: Util.RuntimeOptions): HighlightGameVideoResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.async)) {
    body['Async'] = request.async;
  }
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'HighlightGameVideo',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function highlightGameVideo(request: HighlightGameVideoRequest): HighlightGameVideoResponse {
  var runtime = new Util.RuntimeOptions{};
  return highlightGameVideoWithOptions(request, runtime);
}

async function highlightGameVideoAdvance(request: HighlightGameVideoAdvanceRequest, runtime: Util.RuntimeOptions): HighlightGameVideoResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.isUnset(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new RPC.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'ivpd',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = null;

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var highlightGameVideoReq = new HighlightGameVideoRequest{};
  OpenApiUtil.convert(request, highlightGameVideoReq);

  if(!Util.isUnset(request.videoUrlObject)){
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.endpoint, authResponse.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.objectKey,
      content = request.videoUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.accessKeyId,
      policy = authResponse.encodedPolicy,
      signature = authResponse.signature,
      key = authResponse.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    highlightGameVideoReq.videoUrl =   `http://${authResponse.bucket}.${authResponse.endpoint}/${authResponse.objectKey}`;
  }
  var highlightGameVideoResp = highlightGameVideoWithOptions(highlightGameVideoReq, runtime);
  return highlightGameVideoResp;
}

model ListPackageDesignModelTypesResponseBody = {
  code?: string(name='Code'),
  data?: {
    modelTypeList?: [ 
      {
        elements?: [ 
          {
            sideName?: string(name='SideName'),
          }
        ](name='Elements'),
        modelType?: string(name='ModelType'),
      }
    ](name='ModelTypeList'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model ListPackageDesignModelTypesResponse = {
  headers: map[string]string(name='headers'),
  body: ListPackageDesignModelTypesResponseBody(name='body'),
}

async function listPackageDesignModelTypesWithOptions(runtime: Util.RuntimeOptions): ListPackageDesignModelTypesResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'ListPackageDesignModelTypes',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listPackageDesignModelTypes(): ListPackageDesignModelTypesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listPackageDesignModelTypesWithOptions(runtime);
}

model ListUserBucketsRequest {
  data?: [ 
    {
      regionId?: string(name='RegionId'),
    }
  ](name='Data'),
}

model ListUserBucketsResponseBody = {
  code?: string(name='Code'),
  data?: [ string ](name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model ListUserBucketsResponse = {
  headers: map[string]string(name='headers'),
  body: ListUserBucketsResponseBody(name='body'),
}

async function listUserBucketsWithOptions(request: ListUserBucketsRequest, runtime: Util.RuntimeOptions): ListUserBucketsResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.data)) {
    body['Data'] = request.data;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListUserBuckets',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listUserBuckets(request: ListUserBucketsRequest): ListUserBucketsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listUserBucketsWithOptions(request, runtime);
}

model MakeSuperResolutionImageRequest {
  url?: string(name='Url'),
}

model MakeSuperResolutionImageResponseBody = {
  code?: string(name='Code'),
  data?: {
    url?: string(name='Url'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model MakeSuperResolutionImageResponse = {
  headers: map[string]string(name='headers'),
  body: MakeSuperResolutionImageResponseBody(name='body'),
}

async function makeSuperResolutionImageWithOptions(request: MakeSuperResolutionImageRequest, runtime: Util.RuntimeOptions): MakeSuperResolutionImageResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.url)) {
    body['Url'] = request.url;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'MakeSuperResolutionImage',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function makeSuperResolutionImage(request: MakeSuperResolutionImageRequest): MakeSuperResolutionImageResponse {
  var runtime = new Util.RuntimeOptions{};
  return makeSuperResolutionImageWithOptions(request, runtime);
}

model RecognizeImageColorRequest {
  colorCount?: string(name='ColorCount'),
  url?: string(name='Url'),
}

model RecognizeImageColorResponseBody = {
  code?: string(name='Code'),
  data?: {
    colorTemplateList?: [ 
      {
        color?: string(name='Color'),
        label?: string(name='Label'),
        percentage?: float(name='Percentage'),
      }
    ](name='ColorTemplateList'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model RecognizeImageColorResponse = {
  headers: map[string]string(name='headers'),
  body: RecognizeImageColorResponseBody(name='body'),
}

async function recognizeImageColorWithOptions(request: RecognizeImageColorRequest, runtime: Util.RuntimeOptions): RecognizeImageColorResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.colorCount)) {
    body['ColorCount'] = request.colorCount;
  }
  if (!Util.isUnset(request.url)) {
    body['Url'] = request.url;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'RecognizeImageColor',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function recognizeImageColor(request: RecognizeImageColorRequest): RecognizeImageColorResponse {
  var runtime = new Util.RuntimeOptions{};
  return recognizeImageColorWithOptions(request, runtime);
}

model RecognizeImageStyleRequest {
  url?: string(name='Url'),
}

model RecognizeImageStyleResponseBody = {
  code?: string(name='Code'),
  data?: {
    styles?: [ string ](name='Styles'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model RecognizeImageStyleResponse = {
  headers: map[string]string(name='headers'),
  body: RecognizeImageStyleResponseBody(name='body'),
}

async function recognizeImageStyleWithOptions(request: RecognizeImageStyleRequest, runtime: Util.RuntimeOptions): RecognizeImageStyleResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.url)) {
    body['Url'] = request.url;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'RecognizeImageStyle',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function recognizeImageStyle(request: RecognizeImageStyleRequest): RecognizeImageStyleResponse {
  var runtime = new Util.RuntimeOptions{};
  return recognizeImageStyleWithOptions(request, runtime);
}

model RecolorImageRequest {
  colorCount?: int32(name='ColorCount'),
  colorTemplate?: [ 
    {
      color?: string(name='Color'),
    }
  ](name='ColorTemplate'),
  mode?: string(name='Mode'),
  refUrl?: string(name='RefUrl'),
  url?: string(name='Url'),
}

model RecolorImageResponseBody = {
  code?: string(name='Code'),
  data?: {
    imageList?: [ string ](name='ImageList'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model RecolorImageResponse = {
  headers: map[string]string(name='headers'),
  body: RecolorImageResponseBody(name='body'),
}

async function recolorImageWithOptions(request: RecolorImageRequest, runtime: Util.RuntimeOptions): RecolorImageResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.colorCount)) {
    body['ColorCount'] = request.colorCount;
  }
  if (!Util.isUnset(request.colorTemplate)) {
    body['ColorTemplate'] = request.colorTemplate;
  }
  if (!Util.isUnset(request.mode)) {
    body['Mode'] = request.mode;
  }
  if (!Util.isUnset(request.refUrl)) {
    body['RefUrl'] = request.refUrl;
  }
  if (!Util.isUnset(request.url)) {
    body['Url'] = request.url;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'RecolorImage',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function recolorImage(request: RecolorImageRequest): RecolorImageResponse {
  var runtime = new Util.RuntimeOptions{};
  return recolorImageWithOptions(request, runtime);
}

model SegmentBodyRequest {
  imageUrl?: string(name='ImageUrl'),
}

model SegmentBodyResponseBody = {
  code?: string(name='Code'),
  data?: {
    imageUrl?: string(name='ImageUrl'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model SegmentBodyResponse = {
  headers: map[string]string(name='headers'),
  body: SegmentBodyResponseBody(name='body'),
}

async function segmentBodyWithOptions(request: SegmentBodyRequest, runtime: Util.RuntimeOptions): SegmentBodyResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.imageUrl)) {
    body['ImageUrl'] = request.imageUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'SegmentBody',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function segmentBody(request: SegmentBodyRequest): SegmentBodyResponse {
  var runtime = new Util.RuntimeOptions{};
  return segmentBodyWithOptions(request, runtime);
}

model SegmentCommodityRequest {
  imageURL?: string(name='ImageURL'),
}

model SegmentCommodityResponseBody = {
  data?: {
    imageURL?: string(name='ImageURL'),
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model SegmentCommodityResponse = {
  headers: map[string]string(name='headers'),
  body: SegmentCommodityResponseBody(name='body'),
}

async function segmentCommodityWithOptions(request: SegmentCommodityRequest, runtime: Util.RuntimeOptions): SegmentCommodityResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.imageURL)) {
    query['ImageURL'] = request.imageURL;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SegmentCommodity',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function segmentCommodity(request: SegmentCommodityRequest): SegmentCommodityResponse {
  var runtime = new Util.RuntimeOptions{};
  return segmentCommodityWithOptions(request, runtime);
}

model SegmentImageRequest {
  url?: string(name='Url'),
}

model SegmentImageResponseBody = {
  code?: string(name='Code'),
  data?: {
    url?: string(name='Url'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model SegmentImageResponse = {
  headers: map[string]string(name='headers'),
  body: SegmentImageResponseBody(name='body'),
}

async function segmentImageWithOptions(request: SegmentImageRequest, runtime: Util.RuntimeOptions): SegmentImageResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.url)) {
    body['Url'] = request.url;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'SegmentImage',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function segmentImage(request: SegmentImageRequest): SegmentImageResponse {
  var runtime = new Util.RuntimeOptions{};
  return segmentImageWithOptions(request, runtime);
}

model UpdateUserBucketConfigRequest {
  data?: [ 
    {
      bucket?: string(name='Bucket'),
      region?: string(name='Region'),
    }
  ](name='Data'),
}

model UpdateUserBucketConfigResponseBody = {
  code?: string(name='Code'),
  data?: [ 
    {
      bucket?: string(name='Bucket'),
      region?: string(name='Region'),
      regionName?: string(name='RegionName'),
    }
  ](name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model UpdateUserBucketConfigResponse = {
  headers: map[string]string(name='headers'),
  body: UpdateUserBucketConfigResponseBody(name='body'),
}

async function updateUserBucketConfigWithOptions(request: UpdateUserBucketConfigRequest, runtime: Util.RuntimeOptions): UpdateUserBucketConfigResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.data)) {
    body['Data'] = request.data;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateUserBucketConfig',
    version = '2019-06-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function updateUserBucketConfig(request: UpdateUserBucketConfigRequest): UpdateUserBucketConfigResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateUserBucketConfigWithOptions(request, runtime);
}

